package com.example.laboratory.ui.adapter;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.example.laboratory.R;
import com.example.laboratory.bean.Items;
import com.example.laboratory.common.ListDataHolder;
import com.example.laboratory.widget.LMRecyclerView;

public class CheckItemListAdapter extends BaseListAdapter<Items.ItemListBean> {

    @Override
    protected int getLayoutId(int viewType) {
        return R.layout.item_cehck_list;
    }


    @Override
    public void bindDatas(final ListDataHolder holder, final Items.ItemListBean bean, int itemType, final int position) {
        TextView tv_question = holder.getView(R.id.tv_question);
        RadioButton rbtn_yes = holder.getView(R.id.rbtn_yes);
        RadioButton rbtn_not = holder.getView(R.id.rbtn_not);
        final EditText et_description = holder.getView(R.id.et_description);
        RadioGroup radioGroup = holder.getView(R.id.radio_group);
        tv_question.setText(bean.getItemname());

        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                RadioButton radbtn = (RadioButton) group.findViewById(checkedId);
                if(radbtn.getText().equals("是")){
                    et_description.setVisibility(View.VISIBLE);
                }else {
                    et_description.setVisibility(View.GONE);
                }
               // Toast.makeText(getApplicationContext(), "按钮组值发生改变,你选了" + radbtn.getText(), Toast.LENGTH_LONG).show();
            }
        });
    }

}
